<template>
	<!-- 业务参数 -->
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__dict">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
		  
		  <el-form-item>
			<el-input size="mini" v-model="dataForm.paramValue" :placeholder="$t('dict.dictLabel')" clearable></el-input>
		  </el-form-item>
		<el-form-item>
		  <el-input size="mini" v-model="dataForm.paramKey" :placeholder="$t('baseParam.paramValue')" clearable></el-input>
		</el-form-item>
        
		
        <el-form-item>
          <el-button size="mini" @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button size="mini" v-if="$hasPermission('bizBaseParam:add')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
        </el-form-item>
       <el-form-item>
          <el-button size="mini" v-if="$hasPermission('bizBaseParam:del')" type="danger" @click="delHandle()">{{ $t('deleteBatch') }}</el-button>
        </el-form-item>
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
		 <el-table-column prop="paramKey" :label="$t('baseParam.paramLabel')" header-align="center" align="center"></el-table-column>
		 <el-table-column prop="paramValue" :label="$t('baseParam.paramValue')" header-align="center" align="center"></el-table-column>
		 <el-table-column prop="paramRemark" :label="$t('remark')" header-align="center" align="center"></el-table-column>
       <!-- <el-table-column prop="createUser" :label="$t('createUser')" sortable="custom" header-align="center" align="center" width="180"></el-table-column>
       <el-table-column prop="updateUser" :label="$t('updateUser')" sortable="custom" header-align="center" align="center" width="180"></el-table-column> -->
       <el-table-column prop="createTime" :label="$t('createTime')"  header-align="center" align="center" width="180"></el-table-column>
       <el-table-column prop="updateTime" :label="$t('updateTime')" header-align="center" align="center" width="180"></el-table-column>
	   
	   <el-table-column prop="tagType" :label="$t('baseParam.tagType')"  header-align="center" align="center" width="180">
		   <template slot-scope="scope">
			   <el-tag v-if="scope.row.tagType !== '' && scope.row.tagType !== undefined" :type="scope.row.tagType">{{ scope.row.tagType }}</el-tag>
			   <el-tag v-if="scope.row.tagType === '' || scope.row.tagType === undefined" :type="scope.row.tagType">blue</el-tag>
			</template>
	   </el-table-column>
       
		
		
		<el-table-column  :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('bizBaseParam:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission('bizBaseParam:del')" type="text" size="small" @click="delHandle(scope.row.id)">{{ $t('delete') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="pageNo"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './dict-data-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        createdIsNeed: false,
        getDataListURL: '/pc/'+ (this.$route.params.paramType === 1 ? 'sysBaseParam' : 'bizBaseParam') +'/page',
        getDataListIsPage: true,
        deleteURL: '/pc/bizBaseParam/del',
		deleteIsBatch: true
      },
      dataForm: {
        parentId: '0',
		paramType: ''
      }
    }
  },
  components: {
    AddOrUpdate
  },
  created () {
    this.dataForm.parentId = this.$route.params.parentId || '0'
	this.dataForm.paramType = this.$route.params.paramType
    this.getDataList()
  },
  methods: {
    // 新增 / 修改
    addOrUpdateHandle (id) {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.dataForm.id = id
		this.$refs.addOrUpdate.dataForm.paramType = this.dataForm.paramType
        this.$refs.addOrUpdate.dataForm.parentId = this.dataForm.parentId
        this.$refs.addOrUpdate.init()
      })
    }
  }
}
</script>
